<?php

namespace App\Channels;

use Illuminate\Notifications\Notification;

class SystemChannel
{

    public function send($notifiable, Notification $notification)
    {

        return $notifiable->routeNotificationFor('database', $notification)->create(
            $this->buildPayload($notifiable, $notification)
        );
    }

    protected function buildPayload($notifiable, Notification $notification)
    {
        return [
            'id' => $notification->id,
            'type' => get_class($notification),
            'data' => $notification->toArray($notifiable),
            'read_at' => null,
        ];
    }
}
